let url = 'https://upos-sz-mirror08c.bilivideo.com/upgcxcode/31/21/62131/62131_da3-1-16.mp4?e=ig8euxZM2rNcNbRVhwdVhwdlhWdVhwdVhoNvNC8BqJIzNbfq9rVEuxTEnE8L5F6VnEsSTx0vkX8fqJeYTj_lta53NCM=&uipk=5&nbs=1&deadline=1749333805&gen=playurlv2&os=08cbv&oi=796161031&trid=1b340f9ff85f4657a824bca64858f620h&mid=0&platform=html5&og=hw&upsig=18dad05dd9bfe70b5213e72890b049f8&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,mid,platform,og&bvc=vod&nettype=0&f=h_0_0&bw=28150&logo=80000000'

const https = require('https');
const mime = require('mime-types');

console.log(mime.contentType('mp4'))
console.log(mime.lookup('mp4'))
console.log(mime.getType('mp4'))

const {
    URL
} = require('url');

async function getUrlDetailsWithHeaders(url) {
    try {
        // 1. 解析URL
        const urlObj = new URL(url);
        const urlDetails = {
            href: urlObj.href,
            protocol: urlObj.protocol,
            hostname: urlObj.hostname,
            port: urlObj.port || (urlObj.protocol === 'https:' ? 443 : 80),
            pathname: urlObj.pathname,
            search: urlObj.search,
            hash: urlObj.hash,
            origin: urlObj.origin,
            isSecure: urlObj.protocol === 'https:'
        };

        // 2. 获取响应头
        const headers = await new Promise((resolve) => {
            const req = https.request(url, {
                method: 'HEAD'
            }, (res) => {
                resolve(res.headers);
            });
            req.on('error', () => resolve({}));
            req.end();
        });

        return {
            urlDetails,
            responseHeaders: headers,
            fullInfo: {
                ...urlDetails,
                headers
            }
        };
    } catch (error) {
        return {
            error: error.message
        };
    }
}

// 使用示例
// getUrlDetailsWithHeaders(url)
    // .then(console.log);